package org.shop.common.until;

import java.util.HashMap;
import java.util.Map;

/**
 * 删除空的map key值
 * @author Administrator
 */
public class MapRemoveEmpty<T> {
	
	private Map<String, T> param;
	
	/**
	 * 深拷贝
	 * @param param
	 */
	public MapRemoveEmpty(Map<String, T> param) {
		this.param = new HashMap<String, T>(param);
	}
	
	/**
	 * 移除空的值
	 * @return
	 */
	public Map<String, T> removeEmpty()
	{
		
		if (this.param == null) {
			return new HashMap<String, T>();
		}
		
		Object mapValue;
		
		for(String key : this.param.keySet()) {
			
			mapValue = this.param.get(key);
			
			if (mapValue == null || mapValue == "") {
				this.param.remove(key);
			}
		}
		
		return this.param;
		
	}
	
	public Map<String, T> getParam() {
		return param;
	}

	public void setParam(Map<String, T> param) {
		this.param = new HashMap<String, T>(param);;
	}
	
}
